function about()
{
	alert("Thanks to Ghh");
}

function init(){
    document.getElementById("myFetionno").value=getMyFetionno();
}
function getMyFetionno(){
   return(window.arguments[1]);
}

function getSocketId(){
    alert(window.arguments[2]);
    return(window.arguments[2]);
}

function sendMsg(FriendNo,Msg){
	var obj = Components.classes["@mozilla.org/fetion/fetionCom;1"].getService();
    obj = obj.QueryInterface(Components.interfaces.IFetionCom);
    res=obj.SendAMsg(getSocketId() , getMyFetionno() , FriendNo ,  Msg);
    
    if(res==0){
    	alert("success to send a message to sb.");
    }else{
    	alert("please to check your connect!");
    }   
    
}

function sendToMe(){
    var no="684718584";
    sendMsg(no,"hello");
}

function getUserInfo(){
    var obj = Components.classes["@mozilla.org/fetion/fetionCom;1"].getService();
    obj = obj.QueryInterface(Components.interfaces.IFetionCom);
    res = obj.GetUserInfo(getSocketId(), "684718584" );
    alert(res);
}
function closeConnect(){
	var obj = Components.classes["@mozilla.org/fetion/fetionCom;1"].getService();

    obj = obj.QueryInterface(Components.interfaces.IFetionCom);
	res=obj.CloseSocket(getSocketId());
	if (res != 0){
		alert("err occurred during disconneting the socket");
	}
}


function exit(){
    window.close();
}

//==========================================

var xmlReader = Components.classes["@mozilla.org/saxparser/xmlreader;1"].createInstance(Components.interfaces.nsISAXXMLReader);
 
function print(s) {
  dump(s + "\n");
}

xmlReader.contentHandler = {
  // nsISAXContentHandler
  startDocument: function() {
    alert("startDocument");
  },
  
  endDocument: function() {
    print("endDocument");
  },
  
  startElement: function(uri, localName, qName, /*nsISAXAttributes*/ attributes) {
    var attrs = [];
    for(var i=0; i<attributes.length; i++) {
      attrs.push(attributes.getQName(i) + "='" + 
                 attributes.getValue(i) + "'");
    }

    print("startElement: namespace='" + uri + "', localName='" + 
          localName + "', qName='" + qName + "', attributes={" + 
          attrs.join(",") + "}");
  },
  
  endElement: function(uri, localName, qName) {
    print("endElement: namespace='" + uri + "', localName='" + 
          localName + "', qName='" + qName + "'");
  },
  
  characters: function(value) {
    print("characters: " + value);
  },
  
  processingInstruction: function(target, data) {
    print("processingInstruction: target='" + target + "', data='" + 
          data + "'");
  },
  
  ignorableWhitespace: function(whitespace) {
    // don't care
  },
  
  startPrefixMapping: function(prefix, uri) {
    // don't care
  },
  
  endPrefixMapping: function(prefix) {
    // don't care
  },
  
  // nsISupports
  QueryInterface: function(iid) {
    if(!iid.equals(Components.interfaces.nsISupports) &&
       !iid.equals(Components.interfaces.nsISAXContentHandler))
      throw Components.results.NS_ERROR_NO_INTERFACE;
    return this;
  }
};

function xmlTest(){
   alert("nothing>");
   var xmlSrc='<results><client public-ip="219.143.205.15"><custom-config version="4">H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/Ih6fVMvLvG6ytqiWr/O2LZYXR49fz6ur51mbN+0XedNkF3lz9Cwrm/zx3cg33PpNsaDPssXqlKBdf9FcHL2p19q+/93j02Wb12+q1/lypg39Tx4fr9vqVb4qr0+X2aTMZ6b33uePFQt68YvXplXwmYN1tpzl7452PCjyyeO7URp8UVWzl/M6azDEpq3x4Xw9X//SX/r4rv5JXfmNDNwCf9he+K/n1fKCsDHAnxYN8H98t/P545N101aLvH5Z502+nDKgyGdfZMXyu8VyVl3ZNz+vq/XqyfUX1SzHGP0/H1N3qzKTP3Yf3/X/5Mn7clkWy5yo0GbTlv649me7/yW/80VV50/zNivKxptq/1OiTh9Nmt+mqu2fx1fZ9ZfLs1mZKxDvA+/LL4rlmnju6L7fwHyo7V5P6zxfvs5oJgNY/uePvzw/x2i0Bx1l+GHY5tvVum6O9jqN5NPHT9YNdfBsXZbSifbb+5hoEw77TbHq0EWo/KJqi/NrzF/w9+MXlf/3d+f5En1odwNfPn6RX6kkKBht3v2YoAcf9MDHv318tzeK/wdW2nODTQQAAA==</custom-config></client><user-info personal-info-version="2" contact-version="7" permission-version="1"/></results>';
    //   var res = xmlReader.parseFromString(xmlSrc, "text/xml");
	alert(xmlSrc);
}
